import rhpxl

res_list = ['800x600', '1024x768',
            '1024x800', '1280x1024',
            '1400x1050', '1600x1200']

### LCD
import  rhpxl.guesslcd
print '---------- LCD ----------'
print 'Sync for Res: '
for res in res_list:
    print '\t%s %s' % (res, rhpxl.guesslcd.getSyncForRes(res))

print '---------- Monitor & Videocard (kudzu backport)----------'
import kudzu
devs = kudzu.probe(kudzu.CLASS_MONITOR, kudzu.BUS_DDC, kudzu.PROBE_ALL)
for dev in devs:
    print dev

devs = kudzu.probe(kudzu.CLASS_VIDEO, kudzu.BUS_DDC, kudzu.PROBE_ALL)
for dev in devs:
    print dev

devs = kudzu.probe(kudzu.CLASS_VIDEO, kudzu.BUS_PCI, kudzu.PROBE_ALL)
for dev in devs:
    print dev

print '---------- Monitor (rhpxl)----------'
import  rhpxl.monitor
mon = rhpxl.monitor.MonitorInfo()
print 'Name:\t', mon.monName
print 'ID:\t', mon.monID
print 'Horiz:\t', mon.monHoriz
print 'Vert:\t', mon.monVert
print 'PhyWidth:\t', mon.monPhysicalWidth
print 'PhyHeight:\t', mon.monPhysicalHeight


print '---------- Monitor (edid)----------'
import gtk
import gtk.gdk
root = gtk.gdk.get_default_root_window()
edid = root.property_get("XFree86_DDC_EDID1_RAWDATA")
if not edid:
    print 'EDID not found'
else:
    edid = edid[2]
    name = None
    for x in [ 57, 75, 93, 111 ]:
        if ord(edid[x]) == 0xfc:
            n = edid[x+2:].split('\0')[0]
            n = n.strip()
            if name:
                name = '%s %s' % (name, n)
            else:
                name = n
            print 'Monitor: ', name
        elif ord(edid[x]) == 0xfd:
            print 'Sync: %d-%d' % (ord(edid[x+2]), ord(edid[x+3]))

print '---------- Videocard ----------'
import  rhpxl.videocard
vci = rhpxl.videocard.VideoCardInfo()
print 'Driver\tDescription'
for vc in vci.videocards:
    print 'Driver: %s\tDesc: %s\tVideoRam: %s' % (vc.getDriver(),
                      vc.getDescription(),
                      vc.getVideoRam())
